package com.baifenhao;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

public class StringUtil {
	public static String getSupString(String s){
		Pattern p = Pattern.compile("<(.+?)>");
		Matcher m = p.matcher(s);
		while(m.find()) {
			s = s.replace("<"+m.group(1)+">", "");
		}
		return s;
	}
	public static List<String> findTenDisease(){
		Connection conn = null;
		Statement stat = null;
		List<String> list = new ArrayList<String>();
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = (Connection) DriverManager.getConnection(
					"jdbc:mysql:///", "root","root");
			stat = (Statement) conn.createStatement();
			ResultSet rs1 = stat.executeQuery("select * from t_diseaselink order by id DESC limit 10");
			while(rs1.next()){
				String diseaseLinkName = rs1.getString("diseaseLinkName");
				list.add(diseaseLinkName);
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			
		}
		return list;
	}
	
	
	public static List<String> findTenDiseaseXiaofangjie(){
		Connection conn = null;
		Statement stat = null;
		List<String> list = new ArrayList<String>();
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = (Connection) DriverManager.getConnection(
					"jdbc:mysql:///diseaseoflinkcapture111-2", "root","root");
			stat = (Statement) conn.createStatement();
			ResultSet rs1 = stat.executeQuery("select * from t_diseaselink order by id DESC limit 10");
			while(rs1.next()){
				String diseaseLinkName = rs1.getString("diseaseLinkName");
				list.add(diseaseLinkName);
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			
		}
		return list;
	}
}
